package com.ynwt.domain;

import org.hibernate.annotations.*;

import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * Created by huangying on 2017/5/23.
 */
//@Entity
//@Table(name = "Student")
public class Student {

    private int id;
    private String name;
    private Card card;

    @Id
    @GenericGenerator(name = "PK_Card", strategy = "foreign", parameters = @org.hibernate.annotations.Parameter(name = "property", value = "card"))
    @GeneratedValue(generator = "PK_Card")
    @Column(name = "ID", unique = true, nullable = false)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Column(name = "NAME", nullable = false, length = 50)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, optional = false)
    @PrimaryKeyJoinColumn
    public Card getCard() {
        return card;
    }

    public void setCard(Card card) {
        this.card = card;
    }
}
